home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
errlvl12.zip
/
ERRLVL.DOC
< prev
next >
Wrap
Text File
|
1994-03-08
|
6KB
|
177 lines
ERRLVL, v1.2
-------------
from TifaWARE
What's New
----------
New to version 1.2 is support for DOS v4.0, v5.0, and v6.0. This
required a new approach to locating the ERRORLEVEL. Adding support for
other versions will be easy once the magic offsets are known.
With version 1.1, I have substantially reorganized ERRLVL's source
code, placing commonly-used procedures, equates, and macros in separate
files. Sharing code in this way will make it my programming task easier.
From the user's point of view, however, there's no change.
Version 1.0 was the first public release of ERRLVL.
Introduction
------------
ERRLVL is a simple hack to display the return code from whatever
program COMMAND.COM ran before. Use it when you'd like to know the actual
return code but don't want to bother with statements like:
if ERRORLEVEL 255 echo 255
if ERRORLEVEL 254 echo 254
if ERRORLEVEL 253 echo 243
...
if ERRORLEVEL 1 echo 1
(Geez, why'd Microsoft do it this way?) Additionally, ERRLVL preserves the
value of ERRORLEVEL so you can use it in batch files to maintain detailed
logs of program usage.
Usage
-----
Running ERRLVL is straightforward. Once you've placed the program
where DOS can find it, type ERRLVL -? to display a brief help message
similar to the following:
TifaWARE ERRLVL, v1.2d, 07/07/93 - displays previous ERRORLEVEL.
Usage: errlvl [-options] [msg]
Options:
-? = display this help message
msg is an optional message to display before the errorlevel.
[If you don't remember anything else, at least remember how to display
this help message.]
Typically you'll invoke ERRLVL without arguments. As long as your
shell is COMMAND.COM from a supported version of DOS, ERRLVL will display
the errorlevel; ie, the return code from the preceding program. Also, you
can prefix this with a message, say, to keep track of return codes from a
particular program.
If You Have Any Trouble
-----------------------
ERRLVL will let you know of any problems that arise. Here are the
messages you might see and how you should deal with them:
errlvl: invalid option -- x.
- Type "ERRLVL -?" for a list of valid options.
errlvl: unable to locate errorlevel.
- Make sure you're using COMMAND.COM as the parent
shell and that it's from a supported version of
DOS.
These messages are written to the standard error device. In this way, they
won't disappear down a pipe or into a file should you redirect ERRLVL's
output.
Additionally, ERRLVL exits with the same return code as the previous
program. That is, it preserves the errorlevel. The only exceptions occur
when help is given (return code will be 1) or when the errorlevel cannot
be located (return code will be 10).
Requirements
------------
TifaWARE ERRLVL runs on PC-compatible machines operating under DOS
v3.30, v4.0, v5.0, and v6.0. It requires only 1K of memory. Running it
under 4DOS, MKS Toolkit, or some other COMMAND.COM replacement will not
harm anything, but the value displayed will probably be meaningless.
Adding support for other versions of DOS is fairly easy. You'll need
to figure out where COMMAND.COM stores the errorlevel, and for this you
can use the accompanying program FINDELVL. Issue the following commands:
"findelvl | findelvl 145 147 | findelvl 147 148 | sort > findelvl.out" and
scan the output. With luck it will contain one pair of matching values -
the magic spot - plus a bunch of unique ones. [Refer to FINDELVL.C if it
doesn't.] Once you've uncovered this spot, you can either modify
ERRLVL.ASM (search for ErrLocTbl) and recompile it yourself or contact me.
Who Owns It?
------------
I am releasing this program into the public domain. Since 1984 I have
used public-domain software extensively, and I find it to be a terrific
idea. Most programs are useful, and the source instructive. And they cost
nothing! With this small contribution to the public domain I hope to pay
back my gratitude to those other programmers who have made my computing so
much easier.
However, this program carries no obligation on my part to support
users or provide future upgrades. I try to write clean code and believe it
is "bug-free". Nevertheless, use this program ***AT YOUR OWN RISK***. Scan
the source yourself, make any desired changes, and recompile the program,
if possible. Make this standard practice with newly-acquired software and
you'll not only protect your system from viruses but also get a better
feel for exactly how programs work!
As author of this program, I have two requests: First, please keep
together the original source code, documentation, and executable if you
distribute the package. This just makes it easier for others to use the
software. Second, let me hear what you think of it - I'd appreciate a
postcard with your comments. Enjoy!
Kudos
-----
Many thanks go to Borland for its stand-alone debugger, which greatly
reduced the time spent developing this program. Thanks are also due to
Josep Fortiana Gregori (D3ESJFG0@EB0UB011 on BITNET) who supplied a code
fragment suggesting how to find ERRORLEVEL in RAM and to Yan Juras for
pointing out where exactly to look.
George A. Theall
TifaWARE
610 South 48th St
Philadelphia, PA. 19143
U.S.A.
george@tifaware.com
theall@popmail.tju.edu
theall@mcneil.sas.upenn.edu
george.theall@satalink.com